<?php

class Sfs_View_Helper_StudentNameTable
{
    function StudentNameTable($year_semester,$class_id,$selected='')
    {
        $student  = new Student_Model_Student();
        $arr = $student->getClassStudent($year_semester,$class_id);

        $str = '<table id="student-name-list">';
        $str .= '<thead><tr><th>number</th><th>name</th></tr></thead><tbody>';
        foreach ($arr as $id=>$val){
            if ($val['sex']=='M')
            $class = "option_boy";
            else
            $class = "option_girl";
            if ($selected == $id)
            $str .=  sprintf("<tr id='s-%d' class='%s student_sel'><td>%02d</td><td>%s</td></tr>\n",$id,$class,$val['number'],$val['name']);
            else
            $str .=  sprintf("<tr id='s-%d' class='%s '><td>%02d</td><td>%s</td></tr>\n",$id,$class,$val['number'],$val['name']);

        }
        $str .="</tbody></table>";
        return $str;
    }
}
